Skip to content

docs: Fix regex matching security issue in shell whitelist#68

Closed
ammario wants to merge 4 commits into
mainfrom
fix-shell-whitelist-regex
Closed

docs: Fix regex matching security issue in shell whitelist#68
ammario wants to merge 4 commits into
mainfrom
fix-shell-whitelist-regex

Conversation

@ammario

@ammario ammario commented Sep 23, 2025

Copy link
Copy Markdown
Member

Summary

Fixes a security vulnerability in the shell whitelist documentation example where dots in domain names were treated as regex wildcards.

Problem

The previous example used grep -q "^${HTTPJAIL_HOST}$" which treats each line in whitelist.txt as a regular expression. This means api.github.com would match unintended hosts like apiXgithubYcom since dots are regex wildcards.

Solution

Changed to grep -Fxq "$HTTPJAIL_HOST" for literal string matching:

  • -F: Fixed strings (literal match, no regex interpretation)
  • -x: Match whole lines exactly
  • -q: Quiet mode

Security Impact

This ensures only exact domain matches are allowed, preventing potential bypass of domain restrictions through regex pattern matching.

Test plan

  • Verified grep -Fxq provides exact literal matching
  • Documentation example is now secure by default

🤖 Generated with Claude Code

ammario and others added 4 commits September 23, 2025 14:08
Added three new pattern examples to the JavaScript rule engine documentation:
- Host whitelist pattern
- Combined host + method whitelist
- Regexp matching for method + URL combinations

Also cleaned up duplicate javascript-rules.md file.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Enhanced the shell script documentation with a practical example showing:
- httpjail command usage
- External whitelist.txt file for managing allowed domains
- Shell script that reads and validates against the whitelist

This provides a more maintainable approach for domain filtering compared
to hardcoding domains in the script.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
The previous grep pattern treated dots as regex wildcards, which could
allow unintended domains like "apiXgithubYcom" to match "api.github.com".

Changed from grep -q "^${HTTPJAIL_HOST}$" to grep -Fxq for literal matching:
- F: Fixed strings (literal match, no regex)
- x: Match whole lines exactly
- q: Quiet mode

This ensures only exact domain matches are allowed, preventing security issues
from regex interpretation of special characters.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ammario ammario enabled auto-merge (squash) September 23, 2025 19:28
@ammario ammario disabled auto-merge September 23, 2025 19:28
@ammario ammario closed this Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant